import sys,math,os
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import QDate
class CalendarDemo(QWidget):
    def __init__(self):
        super(CalendarDemo,self).__init__()
        self.initUI()
    def initUI(self):
        self.cal=QCalendarWidget(self)
        self.cal.setMinimumDate(QDate(1990,1,1))
        self.cal.setMaximumDate(QDate(2020,4,18))
        self.cal.setGridVisible(True)
        self.cal.move(20,20)
        self.cal.clicked.connect(self.showDate)
        self.lb1=QLabel(self)
        date=self.cal.selectedDate()
        self.lb1.setText(date.toString("yyyy-MM-dd dddd"))
        self.lb1.move(20,300)
        self.setGeometry(100,100,400,400)
        self.setWindowTitle('CalenDar案例')

    def showDate(self,date):
        self.lb1.setText(date.toString("yyyy-MM-dd dddd"))

if __name__ == '__main__':
    app=QApplication(sys.argv)
    demo=CalendarDemo()
    demo.show()
    sys.exit(app.exec_())
